home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln1085.arc / TURBOGSX.HDC < prev    next >
Text File  |  1986-02-27  |  29KB  |  550 lines

  1.  
  2. @style{spacing 2 lines, notes endnote, indent 5 chars, footpush
  3. no, leftmargin 10 chars, rightmargin 10 chars}
  4. @begin{verbatim}
  5. @CENTER{
  6. ----------------------------------------------------
  7. |            A TURBO GRAPHICS SHELL                |
  8. |      Building an Interface to GSX Graphics       |
  9. |       in Turbo Pascal for the DEC Rainbow        |
  10. ----------------------------------------------------
  11.  
  12. Hubert D. Callihan, Ph.D.
  13. University of Pittsburgh at Johnstown}
  14. @end{verbatim}
  15. @flushleft{Rainbow Graphics Dilemma}
  16.  
  17. Imagine yourself with a DEC Rainbow complete with graphics option
  18. configured and ready to run.   You load the Rainbow Graphics
  19. Interpreter and demos provided by DEC and you proceed to witness
  20. an impressive graphics demonstration exploiting many of the
  21. features including multicolor lines, text in various sizes as
  22. well as colors and orientations, fast polygonal line and circle
  23. generation and fairly fast color fill of regions using a
  24. multitude of possible colors, hatch styles and dithers.  You are
  25. convinced you bought the proper graphics computer.
  26.  
  27. You are now ecstatic and are soon ready to do some of your own
  28. programming to exploit the available graphics calls.  To
  29. your surprise, you find from the Rainbow Graphics Programmer's
  30. Manual that you must learn 8086 assembly language to do it unless
  31. you are willing to spend $500 for Mark William's C language from
  32. DEC.  Quite frankly, you would settle for an interface in Pascal
  33. or even MBASIC-86 but none can be found.   Since you are neither
  34. independently wealthy nor totally familiar with C nor 8086
  35. assembly, you decide to explore alternatives.  After much effort
  36. searching a multitude of references you find no interfaces
  37. available, so you decide to write the interface yourself in the
  38. language of your choice.
  39.  
  40. The above scenario is a typical one for Rainbow owners wanting to
  41. program their machines to exploit the powerful graphics kernel
  42. subroutines available within the Graphics System Extension (GSX)
  43. provided for the Rainbow by Digital Research, Inc.  Most users
  44. who are also programmers may have neither the time nor the
  45. inclination to write the necessary interface software.  I faced
  46. the problem, had the inclination, and took the time.  So in this
  47. article I will supply some basic logic to do the interface and
  48. also provide some Pascal code to implement it.  The complete
  49. Pascal source code is available on disk or hardcopy.  The result
  50. will be a working inexpensive and efficient graphics software
  51. library in Pascal that will provide a nearly interpreter-like
  52. graphics software development environment.   If you do not own a
  53. Rainbow but wish to interface GSX to Pascal, you too should find
  54. it valuable since GSX is available for other microcomputers.
  55. @flushleft{Enter Turbo Pascal!}
  56.  
  57. It made sense to me that if such an interface could be provided
  58. for a popular compiler it would indeed enhance a GSX-equipped
  59. machine's potential for graphics software development.   Since
  60. Pascal is my language choice and since I've had the CP/M-86
  61. version of Borland International's Turbo Pascal running on a
  62. Rainbow at UPJ for nearly a year with great success, I decided to
  63. use it to write the interface to the GSX kernel.@foot{Turbo
  64. Pascal V2.0 Reference Manual.  Borland International, 4113 Scotts
  65. Valley Drive, Scotts Valley, CA 95066.}  The choice, I believe,
  66. was a wise one since Turbo Pascal has been highly acclaimed as
  67. being a versatile, inexpensive ($49.95 + $5.00 shipping), and
  68. excellent performer.@foot{Tom Wadlow.  Turbo Pascal.  @i[BYTE],
  69. July 1984, vol. 9, no. 7, pp. 267-278.}@foot{David D. Clark. 
  70. Turbo Pascal, v.1.01.  @i[Dr. Dobb's Journal], June 1984, no. 92,
  71. pp. 74-78.}@foot{Alan R. Miller.  The Perfect Pascal for CP/M. 
  72. @i[Interface Age], January 1984, pp. 90-92.}@foot{Richard Rodman. 
  73. Turbo Pascal V2.0.  @i[Computer Language], Premier Issue, 1984,
  74. pp. 78-79}@foot{Michael Main, Bob Johnson, Richard Balay, Peter
  75. Baker, Richard Cichelli, Allan McCoy, Donald Slaughter.  Review
  76. Feedback (Turbo Pascal), @i[BYTE], October 1984, vol. 9, no. 11,
  77. pp. 307-308.}@foot{Harry Demarest, Donald Simpson, and Herbert
  78. Kanner.  Turbo Tidbits (Letters to the Editor), @i[Dr. Dobb's
  79. Journal], no. 96, October 1984, pp. 12-13}    So far my
  80. experience with it has given me neither reason to seriously
  81. question any of the previous accolades heaped upon it by its
  82. reviewers nor to disagree with its weaknesses which are few and,
  83. in my judgment, unimportant for micro-based GSX graphics
  84. development.  Borland's latest version (2.0) is used for
  85. development of procedures for this article.  Using an earlier
  86. version should not be a handicap.
  87.  
  88. In what follows, I will present essential information along with
  89. procedures to permit the Turbo Pascal programmer to perform
  90. system calls under CP/M-86 to the Graphics Device Operating
  91. System (GDOS) in GSX.   The complete set of procedures is
  92. included.  You will soon find the manner in which arguments are 
  93. passed to subprograms is quite consistent with documented
  94. requirements in GSX.@foot{Digital Equipment Corporation.
  95. @I[Rainbow GSX-86 Programmer's Reference Manual], no.
  96. AA-V526A-TV}   In addition, those with non-Rainbow systems
  97. running GSX under CP/M-86 or CP/M-80 should find that only the
  98. low-level procedure "CALLGDOS" containing inline machine code
  99. needs to be changed slightly to accommodate other CPUs.   It may
  100. also be true that some of the device-specific ESCAPE functions
  101. would need to be tailored to the functions supported by other
  102. device drivers.   An article by William Wong in the July 1984
  103. issue of @i[Microsystems] describes GSX in detail including the
  104. calling procedure for 8- and 16-bit CP/M, Concurrent CP/M,
  105. Concurrent DOS, PC-DOS, and MS-DOS to permit access to
  106. GSX.@foot{William G. Wong.  Digital Research's GSX:  Graphics
  107. Portability. @i[Microsystems], July 1984, vol. 5, no. 7, pp.
  108. 74-82.}  This should be of great help to Turbo Pascal programmers
  109. wishing to implement "CALLGDOS" on other systems.
  110. @flushleft{GSX Essentials}
  111.  
  112. If you've ever programmed graphics operations on an Apple II or
  113. other graphics devices, you've no doubt experienced the
  114. frustration of tailoring the software package to accommodate
  115. widely divergent hardware approaches to graphics.  There could be
  116. as many versions of one program as there are different devices to
  117. perform the graphics.  Such device-specific software development
  118. is extremely unproductive where portability is a primary concern
  119. as it is in commercial software development.  Of course the
  120. solution to such a dilemma is graphics standardization once we
  121. all know and agree upon what we want as part of that standard
  122. graphics kernel.   When put into place as part of an operating
  123. system's kernel of low-level call resources, such a standard
  124. would provide any supported language the ability to "see" the
  125. graphics kernel's resources from an outer shell perspective. 
  126. Quite apart from the shell and transparent to it, the graphics
  127. kernel  manages at a lower level all requests from the shell to
  128. the device-specific functions such as line drawing, text display,
  129. color filling, etc.  At the shell level, I/O devices are
  130. abstracted according to their general physical function such as
  131. locator, valuator, string, and choice input devices with sample
  132. or request modes available as the devices can support them.
  133.  
  134. The Graphics Kernel System (GKS) is a rich set of two-dimensional
  135. utilities proposed as a first international standard for graphics
  136. functionality which has evolved over a period of years since
  137. about 1963.@foot{ACM SIGGRAPH.  @i[Computer Graphics Special GKS
  138. Issue], Feb. 1984.}@foot{Peter R. Bono, Jose L. Encarnacoa, F.
  139. Robert A. Hopgood, and Paul J. W. ten Hagen.  GKS - The First
  140. Graphics Standard, @I[IEEE Computer Graphics and Applications],
  141. July 1982, vol. 2, no. 5, pp. 9-23.}@foot{Carl Machover and Ware
  142. Myers.  Interactive Computer Graphics, @i[IEEE Computer], October
  143. 1984, pp. 145-161.}@foot{Lansing Hatfield.  Progress in Graphics
  144. Standards (Sidebar to Machover-Ware article), @i[IEEE Computer],
  145. October 1984, p. 155.}@foot{Lansing Hatfield and Bert Herzog. 
  146. Graphics Software -- from Techniques to Principles.  @i[IEEE
  147. Computer Graphics and Applications], Jan. 1982, vol. 2, no. 1,
  148. pp. 59-80.}   GKS distinguishes itself as being easily portable
  149. between machine installations and possessing great potential for
  150. computer graphics software development.@foot{Clinton N. Waggoner. 
  151. The GKS Advantage, Realizing the Potential of Computer Graphics,
  152. @i[Computer Graphics World], October 1984, pp. 19-42.}   This
  153. feature prompted Digital Research, Inc., to incorporate a
  154. significant subset of the GKS standard into an extension of their
  155. 8- and 16-bit operating systems, CP/M-80 and CP/M-86, and IBM's
  156. PC-DOS as well.  It is known commercially as the @u[G]raphics
  157. @u[S]ystem E@u[x]tension (GSX).   However, the problem of
  158. interfacing a language to it will remain until interfaces are
  159. published, whole or in part, or made available by vendors.  This
  160. article provides one such interface and should allow programmers
  161. to take full advantage of Turbo Pascal to develop a multitude of
  162. graphics applications.
  163.  
  164. The essential ingredients of the interface require a modest
  165. understanding of two principal parts of GSX, the @I[Graphics
  166. Device Operating System (GDOS)] and the @I[Graphics Input Output
  167. System (GIOS)].  The application program (in PASCAL or whatever)
  168. requests a specific graphics function to be performed by
  169. executing a call to that function.  GDOS receives the call in its
  170. proper form and eventually passes control to the
  171. hardware-dependent modules in GIOS that have the job of changing
  172. the original service request into commands acceptable to the
  173. peripheral device.  The module that exercises control over the
  174. device is called the @i[device driver].  For each graphics
  175. device, one device driver is required.  The main point here is
  176. that the programmer need @u[not] be concerned with the hardware
  177. specifics of the peripheral but only with the fact that the
  178. correct driver must be loaded as part of GSX at the time of the
  179. request.  The GSX function, OPENWORKSTATION, accomplishes the
  180. loading of the appropriate driver.  It also serves another
  181. purpose.  It returns information to the caller by exhibiting
  182. graphics characteristics of the called device.  For example, the
  183. device may be able to draw a number of different line styles,
  184. fonts, patterns, fill hatch styles, and displayable colors, etc. 
  185. The caller may, upon receiving this information, route control
  186. differently than for a simpler device.  GSX provides for only one
  187. workstation to be open at a time.
  188.  
  189. OPENWORKSTATION is an example of a GSX function available upon
  190. call.   There are many such functions in GSX, and they all
  191. operate by receiving information from the caller, performing the
  192. graphics on the proper device (if possible), and sending back
  193. some status and output information (if any).  These principles
  194. are displayed in Figure 1.
  195. @center{______________________________
  196. insert figure 1 about here
  197. ______________________________}
  198.  
  199. Now, how is a call to GSX actually made?  GSX functions are in
  200. machine code and accessible by number.  For some functions GSX
  201. requires addresses where it can expect to find such items as
  202. number of points, an array of point coordinates, and color codes,
  203. etc.  Therefore, it is natural that GSX employ the idea of a
  204. window in memory which contains the addresses of nearly all
  205. pertinent graphics data to be communicated to and from GSX.  This
  206. window binds the language to GSX and is known as the @i[parameter
  207. block].  GSX also uses the accumulator to return GDOS status
  208. information to the caller.  
  209.  
  210. Specifically, the parameter block consists of pointers to five
  211. arrays elsewhere in memory as declared by the application
  212. program.  Each of these arrays contains the graphics data GSX
  213. needs to perform a function.  If you will now find Figure 2, you
  214. will see that the array sizes may vary from one call to the next
  215. thereby giving the potential, for example, of having GSX plot a
  216. short or long sequence of connected points, called a POLYLINE,
  217. with only one call.  In the case of Pascal, the application
  218. program must declare the maximum sizes of these arrays in TYPE
  219. declarations.  The sequence of points would be placed in the
  220. proper array prior to the call to POLYLINE.  Keep in mind that
  221. the parameter block does not contain actual graphic data but
  222. instead contains pointers to arrays containing the data. 
  223. Therefore, GSX poses no maximum limit on these array sizes.  The
  224. binding requirements of the programming language used to write
  225. the interface and available memory are the factors that pose a
  226. practical limit.  Turbo Pascal presents no problem in this
  227. regard.  On 8-bit machines these pointers are 16-bit machine
  228. addresses, and for 16-bit machines they are 32-bit segment
  229. offsets.  In all cases the arrays consist of 16-bit integers. 
  230. This latter detail will be transparent in this Turbo Pascal
  231. implementation since 16-bit integer types are implemented.
  232. @center{______________________________
  233. insert figure 2 about here
  234. ______________________________}
  235.  
  236. Specifically, the parameter block contains:
  237. @verbatim{
  238.     Pointer 1 . . . to a  @I[CONTROL]           array,
  239.     Pointer 2 . . . to an @I[INPUT PARAMETER]   array,
  240.     Pointer 3 . . . to an @I[INPUT COORDINATE]  array,
  241.     Pointer 4 . . . to an @I[OUTPUT PARAMETER]  array,
  242.     Pointer 5 . . . to an @I[OUTPUT COORDINATE] array.}
  243.  
  244. Each of the above has the same purpose for each GSX function.  The
  245. individual arrays contain information defined specifically for
  246. each GSX function although the usage pattern is consistent from
  247. one to another.  In particular, the CONTROL array contains the
  248. following integer information: 
  249. @begin(verbatim)
  250.  
  251.     1.  GSX Function Code
  252.     2.  Size of Input Coordinate Array
  253.     3.  Size of Output Coordinate Array
  254.     4.  Size of Input Parameter Array
  255.     5.  Size of Output Parameter Array
  256.  
  257. @end(verbatim)
  258. Coordinate array sizes (2 and 3 above) are always required even
  259. if zero.  Naturally, the function code (1) is also required to allow
  260. GDOS to determine which graphics function is to be performed. 
  261. Note in Figure 3 how this control array, along with the window
  262. parameter block, contains the information necessary for GSX to
  263. use the remaining arrays.
  264. @center{______________________________
  265. insert figure 3 about here
  266. ______________________________}
  267.  
  268. For convenience the GSX functions may be grouped to illustrate
  269. common functionality.  Table 1 contains a list of these groups:
  270. @i[Workstation Functions, Line Drawing Functions, Point
  271. Marking Functions, Generalized Drawing Primitives (GDP's), Filled
  272. Area Functions, Text Functions, Color Functions, Mode Control
  273. Functions, Input Functions, and Status Inquiry Functions].  Table
  274. 2 provides a summary of the @i[ESCAPE Functions].  Each is given
  275. with its GSX function code and the Turbo Pascal procedure name
  276. used in subsequent listings.  These functions are
  277. device-independent, except for a few in Table 2 which are
  278. purposely placed within the ESCAPE group where GSX provides for
  279. device-specific functions to occur.  
  280.  
  281. GDOS contains a virtual device interface which performs the
  282. necessary coordinate mapping from @I{Normalized Device
  283. Coordinates (NDC)}, ranging from 0 to 32767 on both x- and
  284. y-axes, to the device-specific real coordinate space determined
  285. by the currently loaded driver.   Although the time consumed by
  286. this transformation may seem unnecessary when compared to
  287. accessing the device directly with device-specific code, the
  288. advantage of device-independence is well worth the small
  289. sacrifice in speed for most applications.  Therefore, high-level
  290. language code for graphics programs developed in this environment
  291. is easily transported to other GSX-supported machines.  
  292.  
  293. Complete details for GSX are too extensive to be presented here
  294. but are well-documented in the references at the end of this
  295. article.  Therefore, I shall provide the major details necessary
  296. to build the software interface between Turbo Pascal and GSX. 
  297. The resulting collection of Turbo procedures and functions will
  298. be referred to hereafter as the
  299. @U{Turbo Graphics Shell}.
  300. @center{________________________________________
  301. insert table 1 and table 2 about here
  302. ________________________________________}
  303. @flushleft{Accessing GSX from Turbo Pascal}
  304.  
  305. Access to GSX from Turbo Pascal must be provided using the window
  306. parameter block once all the arrays have been loaded with the
  307. proper control and graphics information.  In this, the 16-bit
  308. version, GSX is called using software interrupt 224 with function
  309. code 0473 hex in the CX register.  The CX and DX registers are
  310. preserved upon entry and restored upon exit.  Figure 4 contains
  311. the Turbo code in a procedure called CALLGDOS that incorporates
  312. these requirements.  
  313.  
  314. CALLGDOS is then accessed using the Turbo-supplied function
  315. ADDR(@i{arg}), described in the Turbo Reference Manual, which
  316. returns the memory address of @i{arg}.  A call should be in the
  317. form CALLGDOS(ADDR(PB)) where PB contains the integer address of
  318. the window parameter block.  Here I rely on a useful feature of
  319. Turbo Pascal that permits placement of in-line machine code into
  320. the Pascal source code.  (It would be even nicer if it assembled
  321. the mnemonic code since it would prevent having to look up the
  322. hex code for each!  Oh well, for $49.95 you can't expect a
  323. sunroof!)  The code effectively saves registers, loads the CX
  324. register, executes the interrupt, and restores the saved
  325. registers.  For you dyed-in-the-wool Pascal programmers, this is
  326. the only instance where machine code is needed, so don't despair! 
  327. Note however that this procedure is critical to proper
  328. functioning of the interface. 
  329. @center{______________________________
  330. insert figure 4 about here
  331. ______________________________}
  332.  
  333. Once called, GSX looks for the window parameter block and its
  334. associated arrays, performs the graphics operations, and then
  335. returns to the Pascal calling program.  To accomplish this, a
  336. procedure named SETPBLOCK is provided to assist with loading the
  337. pointers into the window parameter block array.  Its
  338. arguments are the five integer pointers (^integer) for each of the
  339. five integer arrays CONTRL, INTIN, PTSIN, INTOUT, and PTSOUT,
  340. corresponding respectively to those required by GSX.  Here
  341. ADDR(PB) returns an address compatible with a
  342. pointer-to-an-integer type (^integer).  Each of these arrays will
  343. be locally declared and therefore dynamically allocated within
  344. each procedure since their sizes often differ.  Thus, a call to
  345. SETPBLOCK would take the form SETPBLOCK (ADDR(CONTRL),
  346. ADDR(INTIN), ADDR(PTSIN), ADDR(INTOUT), ADDR(PTSOUT)).  Finally,
  347. once these arrays are loaded properly with data, all that remains
  348. is a call to SETPBLOCK followed by CALLGDOS.  It should be noted
  349. that the global declarations TYPE PINTEGER:^INTEGER and VAR
  350. PB:ARRAY[1..5] OF PINTEGER are both necessary for any Turbo
  351. Pascal application using this GSX interface.  Since Turbo Pascal
  352. permits multiple CONST, TYPE, VAR, PROCEDURE and FUNCTION
  353. declarations in any order, this global declaration can be
  354. conveniently and inconspicuously placed in one disk file to be
  355. included at compilation time.  In the interest of clarity and
  356. modularity, I have tried to keep such global declarations to a
  357. minimum.  PB is the only globally declared variable name that the
  358. applications programmer should avoid if side effects are to be
  359. prevented.  If you wish, rename it p___b or something unusual and
  360. forget it thereafter.
  361. @center{______________________________
  362. insert figure 5 about here
  363. ______________________________}
  364. @flushleft{Some Demonstration Procedures}
  365.  
  366. The remainder of the Turbo interface to GSX consists of a set of
  367. procedures similar in name to the GSX functions given in Table 1. 
  368. The general six-point strategy for each is to
  369. @begin{verbatim}
  370.  
  371.     1.  Determine necessary value and formal parameters for
  372.             the procedure from the documented input and output 
  373.             requirements for the GSX procedure,
  374.  
  375.     2.  Declare the five integer arrays required by the 
  376.             GSX function,
  377.  
  378.     3.  Place the proper values into the arrays using 
  379.             GSX-defined requirements,
  380.  
  381.     4.  Call SETPBLOCK to establish the parameter block,
  382.  
  383.     5.  Call CALLGDOS to pass control to GSX using the 
  384.         parameter block,
  385.  
  386.     6.  Prepare output (if any) from GDOS and return.
  387.  
  388. @end{verbatim}
  389. Information required by GSX is passed through the formal
  390. parameters of a procedure or function.  Returned information, if
  391. any, is returned using variable parameters in an argument list, a
  392. function value, or in some cases, both.  Once again, to prevent
  393. side effects, global variables are never used to carry
  394. information from an application program to the Turbo Graphics
  395. Shell.
  396. @center{______________________________
  397. insert Figure 6 about here
  398. ______________________________}
  399.  
  400. In Figure 6 for example, the procedure POLYLINE draws lines
  401. sequentially for a given set of points passed to it.  The
  402. argument @I{npts} contains the number of coordinate pairs (x,y)
  403. to be joined with lines in sequence.  The @I{ptsin} parameter
  404. contains a pointer to the first member of an array consisting of
  405. (x,y) points in NDC values stored as x,y,x,y,x,y,x,y, etc.  By
  406. passing the pointer and the array size rather than the array name
  407. itself, one is able to transfer in effect a "variably dimensioned
  408. array" which need not be declared as an array argument of a
  409. procedure within the Turbo Graphics Shell.  Therefore,
  410. declarations of global arrays are unnecessary even though arrays
  411. are being passed through procedure parameter lists.  The
  412. Turbo-supplied function, ADDR(), which returns a pointer to its
  413. argument, is the key to accomplishing this transfer when the
  414. arrays are passed to GSX.
  415.  
  416. GSX requires the control array to be loaded with the properly
  417. defined values.  For example, the definitions of the control
  418. array for POLYLINE are indicated in the CONTRL assignments in
  419. Figure 6a.  Note that @i[intin], @i[intout], and @i[ptsout] might
  420. be declared as single integer variables when they require
  421. dimension 1.  The address of the start of each array is all that
  422. is subsequently passed to the SETPBLOCK procedure.  GSX knows
  423. where to find the proper information if we load the arrays
  424. correctly.  Note in one case, that @i[ptsin] has been transferred
  425. into POLYLINE as an actual address of an integer (^integer),
  426. therefore the ADDR function is not used when @i[ptsin] is passed
  427. along to SETPBLOCK.  Upon return from SETPBLOCK, the parameter
  428. block now contains the addresses of the five GSX arrays, so all
  429. that remains is to transfer the address of the parameter block,
  430. ADDR(PB), to GDOS.  Upon its return the sequenced lines will have
  431. been drawn on the current device.  
  432.  
  433. In other cases where calls are made to the Shell, CALLGDOS will
  434. return information for the caller to process.  For example, in
  435. the INPUTLOCATOR function in Figure 6b, CALLGDOS returns the final x and y
  436. coordinates of the locator device (crosshair, mouse, etc.) in the
  437. @i[ptsout] array, the success status of the input locator device
  438. in CONTRL[5], and the character which terminated the input
  439. locator device in the @i[intout] array.  They are then placed
  440. into the properly named VAR parameters and the function name
  441. variable and returned to the caller of INPUTLOCATOR.  Note also
  442. that GDOS expects to receive the device number for input, the
  443. mode of the input locator's operation, and the initial x-y
  444. graphics cursor position of the locator.  Sample mode implies
  445. that the device will return the x-y coordinates continually as
  446. the device is moved until a terminator character occurs, while
  447. request mode will permit initial positioning of the cursor and a
  448. subsequent final x-y position returned once the terminator
  449. character occurs. 
  450. @center{
  451. ______________________________
  452.  Figure 7 about here
  453. ______________________________}
  454.  
  455. Turbo procedures mentioned in Table 1, which are also detailed in
  456. Listing 1, all operate on the six-point strategy.  Some are
  457. further modularized.  For instance, in Figure 7, quite a few of
  458. the ESCAPE functions, such as ENTERGRAPHICS, call a utility named
  459. ASNCTL which merely assigns transferred values to the control
  460. array and then calls SETPBLOCK and CALLGDOS resulting in a
  461. savings in code size.  Many of the ESCAPE functions differ only
  462. in the values assigned to elements of the control array.
  463. @flushleft{Implementation Notes}
  464.  
  465. The function groups containing the procedures shown in Table 1
  466. should be assigned to separate source code files for inclusion
  467. with an application program when it is to be compiled under Turbo
  468. Pascal.  Turbo does not permit linking to separately compiled
  469. object code files.  Therefore, each GSX function group that is
  470. used must be included from disk as part of the programmer's
  471. source code each time it is compiled.  My advice here is to save
  472. the function groups in separate disk files such as GSXWORK.INC,
  473. GSXLINE.INC, etc. and then use the Turbo "include" compiler
  474. comment option, {$Idrv:filename.ext}, to include the desired
  475. ones, e.g. {$IB:GSXWORK.INC} which will include the file
  476. containing the workstation functions, GSXWORK.INC, from the B:
  477. drive at compilation time.  (You may leave a space between the
  478. "I" and the "B:" in this comment.  However, I like to use Turbo's
  479. TLIST program to selectively list included files, and
  480. unfortunately, TLIST aborts if the space is present in the
  481. comment.  Not a serious problem but, Borland, if you are reading
  482. this, how about fixing it?)
  483.  
  484. Noteworthy here is Turbo's non-standard placement of CONST, TYPE,
  485. VAR, FUNCTION and PROCEDURE declarations permitting any number of
  486. these declarations to occur in any order.  As a matter of
  487. convenience, I chose to hide the global declarations for PINTEGER 
  488. and PB with the workstation functions.  These functions must
  489. always be included as the first included file if the Shell is to
  490. be used.  For example, Listing 2 contains a skeleton program
  491. which suggests how to include the GSX function groups needed for
  492. a typical compilation.  Include only those groups (files) which
  493. contain procedures needed by the application program.  If the
  494. whole Turbo Graphics Shell is included, the programmer can expect
  495. worst case compilation times of about 60 seconds for the Shell
  496. alone.  The full Shell consumes about 9K bytes of memory once
  497. compiled.
  498.  
  499. For those of you who may be neophytes with Turbo Pascal, it is
  500. advisable that the complete code be test-compiled using the
  501. skeleton main program.  The Turbo editor is superb for this
  502. process.  Declare the "MAIN" file as SHELL.PAS and compile it
  503. into memory with the first included file, then the second, etc. 
  504. Typing errors made while entering the included files will be
  505. flagged. The editor will be kind enough to pinpoint the first
  506. error, automatically enter edit mode, and place the cursor on the
  507. error location.  Once the correction is made to source code in an
  508. included file and a request to re-compile is given, the included
  509. file with corrections is automatically saved and the main file is
  510. loaded into memory and compilation begins.  In this way, the
  511. editor provides an excellent semi-intelligent edit/compile/run
  512. environment.  The compiler and editor are sufficiently fast so
  513. that this process resembles a session with an interactive BASIC
  514. interpreter.  Debugging a graphics program is remarkably easy and
  515. fast with Turbo and at times is even enjoyable since there is no
  516. time-consuming link and load process after compilation. 
  517. @flushleft{Final Remarks}
  518.  
  519. The Turbo Graphics Shell contained here conforms to requirements
  520. necessary to interface Turbo Pascal to the Graphics System
  521. Extension (GSX-86 Kernel) available from Digital Research, Inc. 
  522. It provides programmers of GSX-equipped micros running CP/M with
  523. a means to code graphics applications easily and productively
  524. using the full features provided by the edit, compile, and
  525. run-time environment within Turbo Pascal.  The implementer is
  526. expected to be familiar with Pascal and have the necessary device
  527. drivers usually supplied by the machine's vendor.  The Turbo
  528. Graphics Shell described here was implemented successfully on a
  529. DEC Rainbow 100A by the author and is currently being used to
  530. develop a Turbo Graphics Software Tool Kit and numerous
  531. demonstration programs exploiting the features of GSX, the
  532. Rainbow, and Turbo Pascal.
  533.  
  534. Source code for the Shell is available on disk in either Rainbow
  535. or standard 8" CP/M format from the author for $20.00 or may be
  536. downloaded using the @i[Computer Language] Compuserve account. 
  537. Complete source listings and demo programs are available in
  538. hardcopy form from the author for $5.00/set.  Proceeds  will be
  539. given to the University of Pittsburgh at Johnstown ACM Student
  540. Chapter to support student software projects.  Address inquiries
  541. to:
  542. @begin{verbatim}
  543.         Hubert D. Callihan, Ph.D.
  544.         Computer Science Department
  545.         University of Pittsburgh at Johnstown
  546.         Johnstown, Pa 15904
  547. @end{verbatim}
  548. is
  549. expected to be familiar with Pascal and have the necessary device
  550. drivers usually supp